
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>修改信息</title>
    <link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" sizes="32x32" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pg_btn.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.3.2.min.js"></script>
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
</head>

<body>

<div class="x-body">
    <%--把表单封装成一个Admin对象传给服务端--%>
    <form class="layui-form"  id="f_auto" action="${pageContext.request.contextPath}/updateAdmin.action" method="post">
        <input type="hidden" value="${sessionScope.a.aId}" name="aId" id="aId" class="layui-input"/>
        <div class="layui-form-item">
            <label for="aUsername" class="layui-form-label">
                <span class="">用户名</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aUsername" name="aUsername"
                       autocomplete="off" value="${sessionScope.a.aUsername}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="aPassword" class="layui-form-label">
                <span class="">密码</span>
            </label>
            <div class="layui-input-inline">
                <input type="password" id="aPassword" name="aPassword"
                       autocomplete="off" value="${sessionScope.a.aPassword}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="aName" class="layui-form-label">
                <span class="">姓名</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aName" name="aName"
                       autocomplete="off" value="${sessionScope.a.aName}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="aPhone" class="layui-form-label">
                <span class="">电话</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aPhone" name="aPhone"
                       autocomplete="off" value="${sessionScope.a.aPhone}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="aPower" class="layui-form-label">
                <span class="">级别</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aPower" name="aPower"
                       autocomplete="off" value="${sessionScope.a.aPower}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="aDescribe" class="layui-form-label">
                <span class="">级别描述</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aDescribe" name="aDescribe"
                       autocomplete="off" value="${sessionScope.a.aDescribe}" class="layui-input">
            </div>
        </div>




        <input type="submit"  class="layui-btn" id="btn_on" lay-filter="updateAdmin" value="修改">
    </form>
</div>

<script>
    layui.use(['form','layer','laydate'], function(){
        var form = layui.form,
            $ = layui.jquery,
            laydate = layui.laydate;

        $("#f_auto")[0].reset();
        form.on('submit(updateAdmin)', function(data) {

            var param=data.field;

            $.ajax({
                url: '/updateAdmin.action',
                type: "post",
                data: JSON.stringify(param),
                contentType: "application/json; charset=utf-8",
                success:function(){
                    console.log(data);
                    layer.msg('修改成功', {icon: 1, time: 3000});
                    setTimeout(function () {window.location.href='/findAdmin.action';},2000);

                },
                error:function(){
                    console.log(data);
                    layer.msg('修改失败',{icon:0,time:3000});
                    setTimeout(function () {window.location.href='/findAdmin.action';},2000);
                }
            });
        })

    });
</script>
</body>
</html>
